﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class main : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (!Page.Request.FilePath.ToLower().Contains("logout"))
            {
                var account = FifaGamer.Authentication.Get_LoggedInUser();
                if (account != null)
                {
                    #region generate header list items
                    List<HeaderItem> items = new List<HeaderItem>()
                {
                    new HeaderItem() { Value = account.Username, Link = "#" },
                    new HeaderItem() { Value = "Logout", Link = "/Logout.aspx" }
                };

                    ltlHeaderList.Text = "";
                    foreach (var item in items)
                    {
                        ltlHeaderList.Text += item.GetLI();
                    }
                    #endregion
                }
            }
        }
    }

    struct HeaderItem
    {
        public string Value;
        public string Link;

        public string GetLI()
        {
            return string.Format("<li><a href=\"{1}\" style=\"min-width: 80px\">{0}</a></li>", Value, Link);
        }
    }
}
